//
//  HRHearTopicRootViewController.m
//  Hear
//
//  Created by mac on 2018/1/15.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "HRHearTopicRootViewController.h"
#import "HRHearOfAllTopicViewController.h"
#import "HRHearOfTopicListViewController.h"
#import "HRSegmentView.h"
@interface HRHearTopicRootViewController ()
@property(nonatomic, strong)HRHearOfAllTopicViewController *allTopicVC;
@property(nonatomic, strong)HRHearOfTopicListViewController *topicListVC;
@property (nonatomic, strong)HRSegmentView *segmentView;

@end

@implementation HRHearTopicRootViewController
#pragma mark - Get and Set
- (HRSegmentView *)segmentView{
    if (_segmentView == nil) {
        _segmentView = [[HRSegmentView alloc] initWithFrame:CGRectMake(0, 0, 150, 40) andTitleArray:@[@"参与话题",@"全部话题"]];
        WeakSelf
        _segmentView.cutTypeViewBlock = ^(NSUInteger index) {
            if (index == 0){
                weakSelf.allTopicVC.view.hidden = YES;
                weakSelf.topicListVC.view.hidden = NO;
            }else if (index == 1){
                weakSelf.allTopicVC.view.hidden = NO;
                weakSelf.topicListVC.view.hidden = YES;
            }
        };
    }
    return _segmentView;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupView];
    // Do any additional setup after loading the view.
}



- (void)setupView{
    
    self.navigationItem.titleView = self.segmentView;
    
    HRHearOfAllTopicViewController *allTopicVC = [HRHearOfAllTopicViewController new];
    allTopicVC.view.frame = self.view.bounds;
    self.allTopicVC = allTopicVC;
    allTopicVC.view.hidden = YES;

    
    HRHearOfTopicListViewController *topicListVC = [HRHearOfTopicListViewController new];
    topicListVC.view.frame = self.view.bounds;
    topicListVC.view.top = kTopHeight;
    topicListVC.view.height = kScreenHeight-kTopHeight;
    topicListVC.tableView.height = kScreenHeight-kTopHeight;
    self.topicListVC = topicListVC;
    [self addChildViewController:allTopicVC];
    [self addChildViewController:topicListVC];
    [self.view addSubview:allTopicVC.view];
    [self.view addSubview:topicListVC.view];

}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
